
#include "./../loop.h"
#include "./../channel.h"
#include "./../tools/define.h"
#include "./../tools/server.h"
#include "./../tools/connection.h"
#include <cstdio>
#include <gtest/gtest.h>
#include <memory>

TEST(ServerTest, Test)
{
    Loop loop;
    Server server(&loop);
    server.OnMessageCallback([&server](std::shared_ptr<Connection> conn, std::shared_ptr<SocketBuffer> buffer){


        printf("message size : %d and message : %s.\n", buffer->GetBufferLength(), buffer->GetBufferData());
        buffer->FreeBufferData(buffer->GetBufferLength());

    });
    server.ListenServer(9090);
    loop.Run();
}

int main(int argc, const char * argv[])
{
    testing::InitGoogleTest();
    LogModuleConfig config;
    config.m_log_level = "trace";
    config.m_file_name = argv[0];
    LogModule::Instance()->InitModule(config);
    return RUN_ALL_TESTS();
}
